<%-- 
    Document   : Home
    Created on : Apr 2, 2012, 8:54:57 AM
    Author     : Y.Yang
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*,java.util.*"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>UAlbanyBook</title>
        <link rel="stylesheet" type="text/css" href="default.css" />
    </head>
    <body>
    <div id="header">
    <div id="slogan">
    UAlbanyBook
    </div>
    <form name="form1" method="post" action="">
      <label for="Searchbar"></label><input type="text" name="Search" id="Search" size="50">
       <input type="submit" name="search" id="search" value="Search">
      <a id = "headerlink" href="Home.jsp">Home</a>
      <a id = "headerlink" href="Profile.jsp">My Profile</a>
      <a id="w">
      <% if(session.getAttribute("user")== null){
                        response.sendRedirect("Home.jsp");
                    }
                    else
                       out.println("Welcome " +session.getAttribute("user")+"!");%>
      </a> <a id = "headerlink2" href="index.jsp">Sign out</a>
    </form>
    </div>
   
    <div id = "menu">
      <p align="left"><a href="profileBasicInfo.jsp">Basic Information</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profilePicture.jsp">Profile Picture</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profileeduandwork.jsp">Education and Work</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profileArtandEnt.jsp">Arts and Entertainment</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profileWishlist.jsp">Wish List</a></p>
      <p align="left">&nbsp;</p>
      <p align="left"><a href="profileContact.jsp">Contact Information</a></p>
      <p align="left">&nbsp;</p>
</div>
    
    
    <div id = "profile">
      <form name="form2" method="post" action="">
    <p>&nbsp;    </p>
    <p align="center"><strong>Arts and Entertainment</strong></p>
    <p align="center">
      <%
        String URL = "jdbc:mysql://localhost:3306/ualbanybook";
        String USERNAME = "root";
        String PASSWORD = "isaac16";
        Connection connection = null;
        PreparedStatement statement = null;
        ResultSet rstLogin = null;
        //HttpSession session = new HttpSession();
        
        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
            
            statement = connection.prepareStatement("SELECT * FROM useraccount WHERE Email = ?");
            statement.setString(1, (String)session.getAttribute("email"));
            rstLogin = statement.executeQuery();
            while(rstLogin.next())
            {%>
    </p>
    <p><span style="padding-left: 90px">Books:</span>
      <input type="text" name="Books" id="Hometown4" size="50"value="<%out.println(rstLogin.getString("favorbook"));%>">
    </p>
    <br>
    <p><span style="padding-left: 90px">Music:</span>
      <input type="text" name="Music" id="Hometown5" size="50" value="<%out.println(rstLogin.getString("favormusic"));%>">
    </p>
    <br>
    <p><span style="padding-left: 90px">Movies:</span>
      <input type="text" name="Movies" id="Hometown6" size="50" value="<%out.println(rstLogin.getString("favormovie"));%>">
    </p>
    <br>
    <p><span style="padding-left: 90px">TV shows:</span>
      <input type="text" name="TVShows" id="Hometown6" size="50" value="<%out.println(rstLogin.getString("favortvshow"));%>">
    </p>
    <br>
    <p><span style="padding-left: 90px">Arts:</span>
      <input type="text" name="Arts" id="Hometown6" size="50" value="<%out.println(rstLogin.getString("favorart"));%>">
    </p>
    <p align="center">&nbsp;</p>
    <p>
      <%}%>
      <%
      }
        catch(ClassNotFoundException e){
        out.println("Couldn't load database driver: " + e.getMessage());
        }
        catch (SQLException sqlException){
            out.println(sqlException.getMessage());
            
        }  
        finally {            
            try{
                if(connection != null)
                    connection.close();
                if(rstLogin != null)
                    rstLogin.close();
            }
            catch(SQLException ignored){
            out.println(ignored.getMessage()); 
            }
        }
        %>
        </form>
    </p>
    <p>&nbsp;</p>
    <p>&nbsp; </p>
     <form id="formUpdateBasic" method="post" action ="UpdateArtadnEnt">
    <p><span style="padding-left: 90px">Books:</span>
      <input type="text" name="Books" id="Hometown" size="50">
    </p>
    <br>
    <p><span style="padding-left: 90px">Music:</span>
      <input type="text" name="Music" id="Hometown2" size="50">
    </p>
    <br>
    <p><span style="padding-left: 90px">Movies:</span>
      <input type="text" name="Movies" id="Hometown3" size="50">
    </p>
    <br>
    <p><span style="padding-left: 90px">TV shows:</span>
      <input type="text" name="TVShows" id="Hometown3" size="50">
    </p>x
    <br>
    <p><span style="padding-left: 90px">Arts:</span>
      <input type="text" name="Arts" id="Hometown3" size="50">
    </p>
<p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>    
    <p>
      <span style="padding-left: 80px"><input type="submit" name="Signup" id="Signup2" value="Save Changes"></span>
  </p>
    </form>
    </div>
    
    
    
      
    <p>&nbsp;</p>
    </body>
</html>
